﻿@model Patient
@{
    ViewBag.Title = "添加患者";
}
<div id="divAddPatient">
    <h3><a href="#">添加患者</a></h3>
    <div id="divAdd">
    @{using (Ajax.BeginForm<PatientController>(c => c.PatientAdd(null),
        new AjaxOptions { OnBegin = "BeforeSend", OnSuccess = "OnSuccess", OnFailure = "OnError" }))
      {
        <table>
            <tr>
                <th>身份证号</th>
                <td>
                    @Html.HiddenFor(model => model.ID)
                    @Html.TextBoxFor(model => model.IDCard)
                </td>
            </tr>i
            <tr>
                <th>社保号</th>
                <td>
                    @Html.TextBoxFor(model => model.SocialID)
                </td>
            </tr>
            <tr>
                <th>姓名</th>
                <td>
                    @Html.TextBoxFor(model => model.Name)
                </td>
            </tr>
            <tr>
                <th>性别</th>
                <td>@Html.GenderEditorFor(model => model.Gender)</td>
            </tr>
            <tr>
                <th>生日</th>
                <td>@Html.DateEditorFor(model => model.Birthday)</td>
            </tr>
            <tr>
                <th>职业</th>
                <td>@Html.TextBoxFor(model => model.Job)</td>
            </tr>
            <tr>
                <th>地址</th>
                <td>@Html.TextBoxFor(model => model.Address)</td>
            </tr>
            <tr>
                <th>电话</th>
                <td>@Html.TextBoxFor(model => model.Phone)</td>
            </tr>
        </table>
       }
    }
    </div>
</div>
<div id="divUploading">
    正在保存，请稍后...
</div>
<script type="text/javascript">
    $("#divUploading").dialog({
        title: "系统提示",
        autoOpen: false,
        modal: true,
        show: "drop",
        draggable: false,
        resizable: false,
        open: function (event, ui) {
            $("#divUploading").parent("div[role='dialog']").find(".ui-dialog-titlebar-close").hide();
        }
    });
</script>
<div id="divAddSuccess">
    保存成功！
</div>
<script type="text/javascript">
    $("#divAddSuccess").dialog({
        title: "系统提示",
        autoOpen: false,
        modal: true,
        show: "drop",
        draggable: false,
        resizable: false,
        buttons: {
            "确定": function () {
                var url = "@(Url.Action<PatientController>(c => c.PatientDetail(Guid.Empty)))";
                url = url.replace("@(Guid.Empty)", $("#ID").val());
                window.location = url;
            }
        },
        open: function (event, ui) {
            $("#divAddSuccess").parent("div[role='dialog']").find(".ui-dialog-titlebar-close").hide();
        }
    });
</script>
<div id="divUploadError">
    出现错误，请重试！
</div>
<script type="text/javascript">
    $("#divUploadError").dialog({
        title: "系统提示",
        autoOpen: false,
        modal: true,
        show: "drop",
        draggable: false,
        resizable: false,
        buttons: { "确定": function () { $(this).dialog("close"); } }
    });
</script>
<script type="text/javascript">
    function BeforeSend() {
        $("#divUploading").dialog("open");
    }
    function OnSuccess(data) {
        $("#divUploading").dialog("close");
        if (data.ID) {
            $("#ID").val(data.ID);
            $("#divEditSuccess").dialog("open");
        } else
            $("#divUploadError").dialog("open");
    }
    function OnError() {
        $("#divUploading").dialog("close");
        $("#divUploadError").dialog("open");
    }
    $("#divAddPatient").accordion();
</script>